#include "stdio.h"
#include "string.h"

int nozero(int desk[9][9])
{
	int i,j;
	for (i=1;i<=8;++i)
		for (j=1;j<=8;++j)
			if (desk[i][j]==100)
				return 1;
	return 0;
}


main()
{
	int desk[9][9];
	int fromx,fromy,tox,toy;
	int jx,jy;
	unsigned char a,b,c,d,e,f;
	int i,j,k,min;
	char cha,ch1;
	
	cha='a';	
	ch1='0';
	while (scanf("%c%c%c%c%c%c",&a,&b,&c,&d,&e,&f)!=EOF) 
	{
		fromx=a-cha+1;	fromy=b-ch1;
		tox=d-cha+1;	toy=e-ch1;
		
		for (i=0;i<=8;++i)
			for (j=0;j<=8;++j)
				desk[i][j]=100;
		
		desk[fromx][fromy]=0;
		while (nozero(desk))
		{
		for (i=1;i<=8;++i)
			for (j=1;j<=8;++j)
			{
				if ((desk[i][j]>0))
				{
					min=100;
					jx=i-2;
					jy=j-1;
					if ((jx<1)||(jx>8)) jx=0;
					if ((jy<1)||(jy>8)) jy=0;
					if (min>desk[jx][jy]) min=desk[jx][jy];
			
					jx=i-2;
					jy=j+1;
					if ((jx<1)||(jx>8)) jx=0;
					if ((jy<1)||(jy>8)) jy=0;
					if (min>desk[jx][jy]) min=desk[jx][jy];
			
					jx=i+2;
					jy=j-1;
					if ((jx<1)||(jx>8)) jx=0;
					if ((jy<1)||(jy>8)) jy=0;
					if (min>desk[jx][jy]) min=desk[jx][jy];
			
					jx=i+2;
					jy=j+1;
					if ((jx<1)||(jx>8)) jx=0;
					if ((jy<1)||(jy>8)) jy=0;
					if (min>desk[jx][jy]) min=desk[jx][jy];

					jx=i-1;
					jy=j-2;
					if ((jx<1)||(jx>8)) jx=0;
					if ((jy<1)||(jy>8)) jy=0;
					if (min>desk[jx][jy]) min=desk[jx][jy];

					jx=i-1;
					jy=j+2;
					if ((jx<1)||(jx>8)) jx=0;
					if ((jy<1)||(jy>8)) jy=0;
					if (min>desk[jx][jy]) min=desk[jx][jy];

					jx=i+1;
					jy=j-2;
					if ((jx<1)||(jx>8)) jx=0;
					if ((jy<1)||(jy>8)) jy=0;
					if (min>desk[jx][jy]) min=desk[jx][jy];

					jx=i+1;
					jy=j+2;
					if ((jx<1)||(jx>8)) jx=0;              					
					if ((jy<1)||(jy>8)) jy=0;              					
					if (min>desk[jx][jy]) min=desk[jx][jy];					
				
					if (min!=100) desk[i][j]=min+1;	
				}	
			}
		
		}
		printf("To get from %c%c to %c%c takes %d knight moves.\n",a,b,d,e,desk[tox][toy]);                
	}
}





